package com.example.controller;

import com.example.common.Result;
import com.example.entity.Params;
import com.example.service.AiService;
import dev.langchain4j.model.chat.ChatLanguageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping("/ai")
public class AiController {
    private ChatLanguageModel chatLanguageModel;
    @Autowired
    public AiController(ChatLanguageModel chatLanguageModel) {
        this.chatLanguageModel = chatLanguageModel;
    }

    @PostMapping
    public Result getChatResponse(@RequestBody Params params) {
        String response = chatLanguageModel.generate(params.getName());
        return Result.success(response);
    }
}
